﻿import kliment.display.Sprite;
import kliment.ui.ButtonAbstract;
/**
 * ...
 * @author	Kliment
 * @version 1.0.4
 */
class kliment.ui.ButtonListAbstract extends Sprite {
	private var _buttonsList:Array;
	private var _inteval:Number;
	private var _nextX:Number;
	private var _nextY:Number;
	
	public function ButtonListAbstract(target_mc:MovieClip, inteval:Number, isParent:Boolean) {
		super(target_mc, isParent);
		_inteval = inteval || 0;
		_buttonsList = new Array();
	}
	
	public function getByIndex(index:Number):ButtonAbstract {
		return _buttonsList[index];
	}
	
	public function register(target:ButtonAbstract):Void {
		_buttonsList.push(target);
		target.addListener(this);
	}
	
	private function onRelease(target:ButtonAbstract):Void {
		target.onRelease(target);
		target.onClick(target);
	}
	
	private function onRollOver(target:ButtonAbstract):Void {
		target.setFocus();
	}
	
	private function onRollOut(target:ButtonAbstract):Void {
		target.resetFocus();
	}
	
	private function onReleaseOutside(target:ButtonAbstract):Void {
		target.resetFocus();
	}
	
	public function get length():Number { return _buttonsList.length }
	
	public function remove():Void {
		var i:Number = _buttonsList.length;
		var item:ButtonAbstract;
		while (i--) {
			item = _buttonsList[i];
			item.remove();
		}
		delete _buttonsList;
		super.remove();
	}
}